#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<fcntl.h>
#include<errno.h>
#include<string.h>

int main(int argc,char **argv)
{
    int               i,fd;
    struct stat       statbuf;
    struct timespec   times[2];

    for(i=1;i<argc;i++)
    {
        if(stat(argv[i],&statbuf)<0)
        {
            printf("%s stat error: %s\n",argv[i],strerror(errno));
            continue;
        }

        if((fd = open(argv[i],O_RDWR|O_TRUNC))<0)
        {
            printf("%s open error: %s\n",argv[i],strerror(errno));
            continue;
        }

        times[0]=statbuf.st_atim;
        times[1]=statbuf.st_mtim;

        if(futimens(fd,times)<0)
        {
            printf("%s futimes error: %s\n",argv[i],strerror(errno));
        }
 
        close(fd);
        
    }
    return 0; 

}
